/*
 * TCPSocketSSL.h
 *
 *  Created on: 2011-3-5
 *      Author: lionxing
 */

#ifndef TCPSOCKETSSL_H_
#define TCPSOCKETSSL_H_
#include <e32base.h>
#include <es_sock.h>
#include <in_sock.h>
#include <SecureSocket.h> 
#include "TCPSocketTimer.h"

#include "TCPSocketSSLSend.h"
#include "TCPSocketSSLRev.h"
typedef enum 
{
	SSLHANDSHAKE,
	SSLSEND

}SLLStatus;

class CTCPSocketSSL : public CActive,MObserverRevSSL , MObserverSendSSL
{
public: // Observer interface
	class MObserver
	{
	public:
		virtual void OnSendSSL(const TDesC8& aMsg, TInt aError) = 0;
		virtual void OnRevSSL(const TDesC8& aMsg, TInt aError) = 0;
		virtual void OnHandComplete(TInt aError)=0;
	};

public:
	static CTCPSocketSSL* NewL(MObserver& aObserver, RSocket& aSocket);
	// C++ constructor
	CTCPSocketSSL(MObserver& aObserver, RSocket& aSocket);
	void ConstructL();
	// Cancel and destroy
	~CTCPSocketSSL();

public:
	virtual void OnReceiveSSL(const TDesC8& aData, TInt aError) ;
	virtual void OnSendSSL(const TDesC8& aMsg, TInt aError) ;
	
public:
	void SendSSL(const TDesC8& des);
	void RevSSL();

private: // From CActive
	// Handle completion
	void RunL();
	
	// How to cancel me
	void DoCancel();


private: // member variables
	MObserver& iObserver;
	RSocket& iSocket;

private:
	CSecureSocket* iSSLSocket;
	CTCPSocketSSLRev* iSSLRev;
	CTCPSocketSSLSender* iSSLSend;
};

#endif /* TCPSOCKETSSL_H_ */
